package com.lanzuo.collector.updater.test;

import com.lanzuo.collector.updater.service.FileUpdateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Slf4j
@Configuration
public class AutoUpdaterComponent implements CommandLineRunner {

    @Resource
    FileUpdateService fileUpdateService;

    @Override
    public void run(String... args) throws Exception {
//        nginxFileInterface.downloadFileDemo("eap-pana-mounter-adapter.jar", progress -> {
//            System.out.println("total bytes: " + progress.getTotalBytes());   // 文件大小
//            System.out.println("current bytes: " + progress.getCurrentBytes());   // 已下载字节数
//            System.out.println("progress: " + Math.round(progress.getRate() * 100) + "%");  // 已下载百分比
//            if (progress.isDone()) {   // 是否下载完成
//                System.out.println("--------   Download Completed!   --------");
//            }
//        });

        fileUpdateService.start();
        log.info("fileUpdateService.start....");
    }
}
